<admintpl file="header"/>
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Admin/News/index')}">新闻列表</a></li>
        <li class="active"><a >修改{$Title}</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form" id="form.js-ajax-forms"
          action="{:U('Admin/News/NewsPost')}">
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">关键字：</label>
            <div class="span3">
                <input type="text" name="newsKey" value="{$news['keyWords']}" style="width: 556px;">
            </div>
        </div>

        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">新闻标题：</label>
            <div class="span3">
                <input type="text" name="newsTitle" value="{$news['title']}"  style="width: 556px;">
            </div>
        </div>
        <div class="control-group">
            <label class="span2 control-label" style="width: 90px;">新闻摘要：</label>
            <div class="span7">
                <textarea style="width: 556px; height: 60px;" name="newsVeneto">{$news['summary']}</textarea>
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">新闻来源：</label>
            <div class="span3">
                <input type="text" name="newsSource" value="{$news['source']}"   style="width: 556px;">
            </div>
        </div>

        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">新闻分类：</label>
            <div class="span3">
                <select class="select_2" name="category" id="category">
                    <option>全部</option>
                    <foreach name="category" item="vo">
                        <option value="{$vo.cId}">{$vo.cN}</option>
                    </foreach>
                </select>
            </div>
            <label class="span1 control-label" style="width: 90px;">分类标签：</label>
            <div class="span3">
                <select class="select_2" name="tags" id="tags">
                    <option value="0">全部</option>
                </select>
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">所属地区：</label>
            <div class="span3">
                <select class="select_2" name="province" id="province">
                    <option>全部</option>
                    <foreach name="province" item="vo">
                        <option value="{$vo.aId}">{$vo.aN}</option>
                    </foreach>
                </select>
            </div>
            <div class="span3">
                <select class="select_2" name="city" id="city">
                    <option value="0">全部</option>
                </select>
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">标题图片：</label>
            <div style="padding-left: 130px;text-align: left;">
                <input type="hidden" name="imageUrl" id="imageUrl" value="{$news['titleImg']}">
                <a href="javascript:void(0);"
                   onclick="flashupload('thumb_images', '附件上传','imageUrl',thumb_images,'1,jpg|jpeg|gif|png|bmp,1,,,1','','','');return false;">
                    <img src="{$news['titleImg']}"  id="imageUrl_preview" width="135"
                         style="cursor: hand"/>
                </a>
            </div>
        </div>
        <div class="control-group">
            <label class="span2 control-label" style="width: 90px;">新闻正文：</label>
            <div class="span9">
                <script type="text/plain" id="content" name="newsContent">{$news['newsContent']}</script>
            </div>
        </div>
        <div class="form-actions" style="padding-left:260px;">
            <input type="hidden" name="newsId" value="{$news['newsId']}">
            <button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
            &nbsp;&nbsp;<a class="btn" href="{:U('Admin/News/index')}">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.DIMAUB;
</script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript"
        src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var flag = true;
        $('#province').change(function () {
            $.get('{:U("Admin/News/getCity")}' + '&pid=' + $('#province').val(), function (data) {
                var html = '<option value="0">--无--</option>';
                if (data['state'] == "success") {
                    html = '<option value="0">全部</option>';
                    for (var a in data.data) {
                        html += '<option value="' + data.data[a].aId + '">' + data.data[a].aN + '</option>';
                    }
                }
                $('#city').html(html);
                if (flag) {
                    $('#city').val("{$news['areaId']}");
                }
                flag = false;
            });
        });
        $('#province').val("{$news['provinceId']}");
        $('#province').change();

        var cateFlag=true;
        $('#category').change(function () {
            $.get('{:U("Admin/News/getTags")}' + '&cId=' + $('#category').val(), function (data) {
                var html = '<option value="0">--无--</option>';
                if (data['state'] == "success") {
                    html = '<option value="0">全部</option>';
                    for (var a in data.data) {
                        html += '<option value="' + data.data[a].tagId + '">' + data.data[a].tagName + '</option>';
                    }
                }
                $('#tags').html(html);
                if (cateFlag) {
                    $('#tags').val("{$news['subjectTagId']}");
                }
                cateFlag = false;
            });
        });
        $('#category').val("{$news['categoryId']}");
        $('#category').change();

    });
</script>
<script type="text/javascript">
    $(function () {
        //编辑器
        editorcontent = new baidu.editor.ui.Editor();

        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }
        //增加编辑器验证规则
        jQuery.validator.addMethod('editorcontent', function () {
            try {
                editorcontent.sync();
            } catch (err) {
            }
            return editorcontent.hasContents();
        });
        var form = $('form.js-ajax-forms');
        //ie处理placeholder提交问题
        if ($.browser.msie) {
            form.find('[placeholder]').each(function () {
                var input = $(this);
                if (input.val() == input.attr('placeholder')) {
                    input.val('');
                }
            });
        }
    });
</script>
</body>
</html>